<?xml version="1.0" encoding="UTF-8" ?>
<!--
    page description : 근태관리 - 관리자 - 사원관리 화면 - 사원등록/수정 (pop_up)
    author      : Yang D
    date        : 2009-02-04
    file name   : emp_mgr_reg_auth_p.jsp
-->
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:directive.page import="attend.com.CodeMetrix"/>
<%@ taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<s:head theme="ajax"/>
	
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="/inc/css/common.css" />
	<link rel="stylesheet" type="text/css" href="style/style.css" />
	<link rel="stylesheet" type="text/css" href="/inc/css/dhtmlxcalendar.css" />

	<script type="text/javascript" src="/inc/js/common.js"></script>
	<script type="text/javascript" src="/js/common.js"></script>
	<script type="text/javascript" src="/js/dhtmlXCommon.js"></script>
	<script type="text/javascript" src="/js/dhtmlxcalendar.js"></script>
	
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>사원관리-휴직정보-</title>
	<script type="text/javascript">

		function doOnLoad(){

				if ('<s:property value="msg" />' == "<%= CodeMetrix.DUPLICATE%>") {

					alert("<s:text name="alert.message.duplicatevacation" />");
					window.close();
					return false;
				}

				if ('<s:property value="msg" />' == "<%= CodeMetrix.OK%>") {

					alert("<s:text name="alert.message.saved" />");
					window.close();
					return false;
				}

	
			var today = new Date();
			var year = today.getYear();
			var month = today.getMonth() + 1;
			var date = today.getDate();
	
			if(month < 10){
				month = "0" + month;
			}
			if(date < 10){
				date = "0" + date;
			}
			document.getElementById('reg_date').value = year + "-" + month + "-" + date
	
			var str = year + "-" + month + "-" + date ;

			cal1 = new dhtmlxCalendarObject('vaca_sdate', false, {isYearEditable: true});
			cal1.setYearsRange(2000, 2050);
			cal1.setPosition(20,-82);
			cal1.draw();
			//cal1.setOnClickHandler(selectDate1);

			cal2 = new dhtmlxCalendarObject('vaca_edate', false, {isYearEditable: true});
			cal2.setYearsRange(2000, 2050);
			cal2.setPosition(20,-82);
			cal2.draw();
			//cal2.setOnClickHandler(selectDate2);

			cal3 = new dhtmlxCalendarObject('reg_date', false, {isYearEditable: true});
			cal3.setYearsRange(2000, 2050);
			cal3.setPosition(20,-82);
			cal3.draw();
			cal3.setOnClickHandler(selectDate3);

			document.getElementById('vaca_sdate').onfocus = function() { if (cal2.isVisible()) cal2.hide(); }
			document.getElementById('vaca_edate').onfocus = function() { if (cal1.isVisible()) cal1.hide(); }
			document.getElementById('reg_date').onfocus = function() { if (cal1.isVisible()) cal1.hide(); }

			document.body.onclick = function(){calendarHide("cal1,cal2,cal3","D");};

			



		         //if((parseInt(document.getElementById("popup_550se_bg").offsetHeight) - parseInt(window.document.body.clientHeight)) > 20 ){

		          //       window.document.body.scroll = "auto";
		          //       window.resizeBy(0,0);
		         //}

				//document.getElementById("img_save").focus();

			
		}

		function selectDate1(date)
		{
			document.getElementById('vaca_sdate').value = cal1.getFormatedDate(null,date);
			dateTo = new Date(date);
			dateFrom = null;
			cal1.setSensitive(dateFrom, dateTo);
			cal1.hide();
			return true;
		}

		function selectDate2(date)
		{
			document.getElementById('vaca_edate').value = cal2.getFormatedDate(null,date);
			dateTo = new Date(date);
			dateFrom = null;
			cal1.setSensitive(dateFrom, dateTo);
			cal2.hide();
			return true;
		}

		function selectDate3(date)
		{
			document.getElementById('reg_date').value = cal1.getFormatedDate(null,date);
			dateTo = new Date(date);
			dateFrom = null;
			cal1.setSensitive(dateFrom, dateTo);
			cal3.hide();
			return true;
		}
		

		function fnc_auto_add_tr() {
		
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			
			target.appendChild(tr);
			target.appendChild(td);
		    
		}
		
		/**
	    *그룹선택이 변경될 경우에 팀과 사원  list를 변경한다.
	    */
	    function selectChange(f) {
	    	
	    	if (f == "team") return false;
	    	
	    	var idx = f.group_no.selectedIndex;
	    	var opt = f.group_no.options[idx];
	    	
	    	f.sgroup.value = opt.value;
	    	
			dojo.event.topic.publish("show_team");
			return false;
		}
		
		function isValidate(f) {
			//validation
			if (typeof f.group_no == undefined) {
				alert("<s:text name="alert.message.notSave" />");
				return false;
			}
			
			var idx = f.group_no.selectedIndex;
	    	var opt = f.group_no.options[idx];
	    		
	    	var tidx = f.steam.selectedIndex;
	    	var topt = f.steam.options[tidx];
	    	
	    	if (idx != 0 && tidx == 0) {
	    		alert("권한을 추가할 팀을 \n\n올바르게 선택하여 주시기 바랍니다.");
	    		f.group_no.selectedIndex = 0;
	    		return false;
	    	}
	    	
	    	if (typeof f.a_team_no.length == "undefined") {
	    		if (opt.value.length == 0) {
	    			alert("<s:text name="alert.message.selectGroupname" />");
		    		f.group_no.focus();
		    		return false;
	    		}
	    		
	    		if (topt.value == "ALL") {
	    			alert("<s:text name="alert.message.selectTeamName" />");
		    		f.steam.focus();
		    		return false;
	    		}
	    		
	    		//팀코드를 넘긴다.
    			f.a_team_no.value = topt.value;
    		
	    	} else {
	    		f.a_team_no[f.a_team_no.length - 1].value = topt.value;	//팀코드를 히든으로 전달한다.
	    	}

			return true;
		}
		
		//사원 휴직정보 저장
		function fnc_submit_vacation(f) {

				var sdate = f.vaca_sdate.value;
		    	var edate = f.vaca_edate.value;
		    	var rdate = f.reg_date.value;
		    	var remark = f.vaca_remark.value;
	
				if ( sdate == "" || sdate == null ){
					alert("휴직시작일을 입력해 주세요.");
					return false;
		        }
	
		    	if ( edate == "" || edate == null ){
					alert("휴직종료일을 입력해 주세요.");
					return false;
		        }
	
		    	if ( rdate == "" || rdate == null ){
					alert("배정일자를 입력해 주세요.");
					return false;
		        }
	
		    	if ( remark == "" || remark == null ){
					alert("휴직사유를 입력해 주세요.");
					return false;
		        }
	
		        /*for(var i=0; i<remark.length; i++){
		           if(remark.charAt(i)==" ")
		               cnt++
		        }
	
		        if(remark.length == cnt){
		           alert("휴직사유에 공백을 허용하지 않습니다.");
		           f.vaca_remark.focus();
		           return false;
		        }*/
	
		    	if ( sdate > edate ) {
					//alert("입사일이 현재일보다 이전입니다.\n재직여부를 'Y'로 변경하십시오.");
					alert("휴직종료일이 시작일보다 이전입니다.\n올바르게 입력해 주십시오.");
					return false;
				}

		    	if(confirm("휴직정보를 수정하시겠습니까?")){
					
					f.action = "updateEmpVacation_p.action";
			    	f.submit();
	
	
			    	//if ('<s:property value="msg" />' == "<%//= CodeMetrix.DUPLICATE%>") {
	
			    				//alert("<s:text name="저장되었습니다." />");
			    				//window.close();
			    				//return false;
			    	//	}
				//}
				
				return false;
			}else{
				return false
			}
		}

		//휴직 삭제
		function fnc_delete_submit(f) {
			//alert("here!!");
			if(confirm("휴직정보를 정말 삭제하시겠습니까?")){
				fnc_check(f);
				//alert("f>>>"+f);
				//alert("a");
				
				//hidden값에 체크된 emp_no 담기
				//document.frm2.getElementById("ch_seq_no").value = args;
				//document.frm2.ch_seq_no.value = args;
				//alert("args>>>"+args);
				//alert("document.frm2.ch_seq_no.value>>>"+document.frm2.ch_seq_no.value);
				//alert("b");
		
				document.frm3.action = "deleteEmpVacation_p.action"   //form action 설정.
				document.frm3.submit();
		        
				return false;
			}else{
				return false;
			}
		}




	  

	</script>
</head>
<body onload="doOnLoad();">
	<div id="popup_850se_top" ></div>
    <div id="popup_800se_bg">
        <s:form name="frm" id="frm" method="post" theme="simple">
        	<s:hidden name="msg" 		/>				<!-- 저장 메시지 출력 -->
        	<s:hidden name="crud_type"	/>
        	<input type="hidden" name="h_emp_no" id="h_emp_no" value="<s:property value="emp_no" />" />
			<table class="pop800se_Tbl" border="1">
				<tr>
					<!--td class="th_header" style="text-align:center;"><input type="checkbox" id="selectAll" name="selectAll" onclick="selectCheck()" /></td-->
					<!--td class="th_header" style="text-align:center;">삭제</td>
					<td class="th_header" style="text-align:center;">순번</td-->
					<td class="th_header" style="text-align:center;">성명</td>
					<td class="th_header" style="text-align:center;">휴직시작일</td>
					<td class="th_header" style="text-align:center;">휴직종료일</td>
					<td class="th_header" style="text-align:center;">휴직유형</td>
					<td class="th_header" style="text-align:center;">휴직배정일자</td>
					<td class="th_header" style="text-align:center;">휴직사유</td>
				</tr>
				<s:iterator value="list" id="iter" status="row">
				<tr>
					<input type="hidden" id="d_chk" name="d_chk" value="<s:property value="seq"/>" <s:if test='close_dt == "Y"' >disabled="disabled"</s:if> />
			        <s:hidden name="seq" />
			        <input type="hidden" name="a_seq" value="<s:property value="seq"/>" />
			        <!--td style="text-align:center;"><s:property value="emp_nm"/><input type="hidden" name="a_emp_no2" value="<s:property value="emp_nm"/>" /></td-->
			        <td style="text-align:center;"><s:property value="emp_info.emp_nm"/><s:hidden name="emp_no"/></td>
			        <td style="text-align:center;"><input type="text" size="12" maxlength="10" name="vaca_sdate" id="vaca_sdate" value="<s:property value="vaca_sdate" />" style="height:20;background-image:url('images/calendar/calendar.gif');background-repeat:no-repeat;background-position:right 2px;cursor:hand" /></td>
			        <td style="text-align:center;"><input type="text" size="12" maxlength="10" name="vaca_edate" id="vaca_edate" value="<s:property value="vaca_edate" />" style="height:20;background-image:url('images/calendar/calendar.gif');background-repeat:no-repeat;background-position:right 2px;cursor:hand" /></td>
			        
			    <s:if test='vaca_kind == 2001' >
			        <td style="text-align:center;"><s:select id="vaca_kind" name="vaca_kind" list="#{'2001':'유급(연차휴가)' , '2005':'무급(기타휴가)'}" cssClass="combobox100se"/></td>			       
			    </s:if>
			    <s:if test='vaca_kind == 2005' >
			    	<td style="text-align:center;"><s:select id="vaca_kind" name="vaca_kind" list="#{'2005':'무급(기타휴가)' , '2001':'유급(연차휴가)'}" cssClass="combobox100se"/></td>			       
			    </s:if>    

			        <!--td style="text-align:center;"><s:select id="vaca_kind" name="vaca_kind" list="#{'2001':'유급휴가(연차휴가)' , '2005':'무급휴가(기타휴가)'}" cssClass="combobox130se"/></td-->
			        <td style="text-align:center;"><input type="text" size="12" maxlength="10" name="reg_date" id="reg_date" value="<s:property value="reg_date" />" style="height:20;background-image:url('images/calendar/calendar.gif');background-repeat:no-repeat;background-position:right 2px;cursor:hand" /></td>			        
			        <td style="text-align:center;"><input type="text" maxlength="30" name="vaca_remark" id="a_vaca_remark" value="<s:property value="vaca_remark" />" ></input></td>
			    </tr>
				</s:iterator>
			</table>
			<br></br><br></br>
			<div id="popup_btn">
				<s:submit type="image" name="img_save" id="img_save" src="/images/btn_save.gif" value="저장" onclick="return fnc_submit_vacation(this.form)"/>
				&nbsp;<s:submit type="image" name="img_save2" id="img_save2" src="/images/btn_sdelete.gif" value="삭제" onclick="return fnc_delete_submit(frm2)"/>
			</div>
			<br></br><br></br>
		    <!---------------Bottom : STR----------->
			<div id="popup_800se_bottom"><img src="/images/pop_btn_close.gif"  onclick="window.close();" style="cursor: pointer;"/></div>
			<!---------------Bottom : END----------->
        </s:form>
        
    </div>
    
</body>
</html>